<template>
    <div class="home">
        <div class="common-header">
            <div class="header mn">
                <div class="logo">
                    <img alt="" src="../assets/logo1.png">
                    <div class="txt">
                        <div class="tt">济南域潇集团有限公司</div>
                        <div class="tt">招投标系统</div>
                    </div>
                </div>
                <div class="nav">
                    <div v-for="(item,index) in nav" class="navitem" @click="GetLinkUrl(index)">
                        {{ item.name }}
                    </div>
                    <div class="login" v-if="!token" @click="GetLogin()">
                        登录/注册
                    </div>
                </div>
            </div>
        </div>
    </div>

</template>

<script setup>
/**
 * 组件引入
 */
import {onMounted, reactive, ref} from 'vue'
import {useRouter} from 'vue-router'
import Cookies from "js-cookie";
import msg from "../utils/Message.js";
/**
 * 全局变量
 * @type {UnwrapNestedRefs<{count: string, list: *[]}>}
 */
const router = useRouter()
const token = Cookies.get("token")
// 导航
var nav = reactive([
    {
        id: 1,
        name: "首页",
    }, {
        id: 2,
        name: "招标项目",
    }, {
        id: 3,
        name: "消息中心",
    }
])



/**
 * 页面挂载后
 */
onMounted(() => {

});


/**
 * 方法区
 */

// 登录

function GetLogin(){
    router.push('/login')
}

// 跳转
function GetLinkUrl(index) {
    if(index == 0){
        router.push('/')
    }
    if(index == 1){
        router.push('/cases')
    }
    if(index == 2){
        if (!token) {
            msg.message("您未登录，请登录", 'error')
            return
        }
        router.push('/message')
    }

}



</script>

<style lang="scss" scoped>
@import '../assets/scss/index.scss';
</style>
